package com.csgz.camera.biz

import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.animation.BounceInterpolator
import androidx.core.animation.doOnEnd
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.splashscreen.SplashScreenViewProvider
import androidx.lifecycle.lifecycleScope
import com.banmen.ad.mds.views_notload.DoubleSplashAd
import com.bytedance.sdk.openadsdk.CSJSplashAd
import com.csgc.camera.base.BaseActivity
import com.csgc.camera.biz.MainActivity
import com.csgc.camera.util.SpUtils
import com.csgc.camera.widget.dialog.NoNetWorkDialog
import com.csgc.camera.widget.dialog.UserAgreementDialog
import com.cysd.spsyxj.databinding.ActivitySplashBinding
import com.gyf.immersionbar.ktx.immersionBar
import com.hlyj.http.base.tool.lib_hlyj_base.BaseApplication
import com.hlyj.http.base.tool.lib_hlyj_base.Constants
import com.hlyj.http.base.tool.lib_hlyj_base.ProductEnvConstance
import com.hlyj.http.base.tool.lib_hlyj_base.bean.BaseResult
import com.hlyj.http.base.tool.lib_hlyj_base.bean.GetadswitchResultBean
import com.hlyj.http.base.tool.lib_hlyj_base.net.ApiCallback
import com.hlyj.http.base.tool.lib_hlyj_base.net.AppRiskConfigBean
import com.hlyj.http.base.tool.lib_hlyj_base.utils.BaseAppConstans
import com.hlyj.http.base.tool.lib_hlyj_base.utils.BaseModuleSpUtils
import com.hlyj.http.base.tool.lib_hlyj_base.utils.DeviceModeUtil
import com.hlyj.http.base.tool.lib_hlyj_base.utils.JsonUtil
import com.hlyj.http.base.tool.lib_hlyj_base.utils.MMKVUtils
import com.hlyj.http.base.tool.lib_hlyj_base.utils.Tool
import com.hnyyac.ad.mds.utils.BaseAdConstants
import com.hnyyac.ad.mds.views_notload.IAdviewNotLoadSplashListener
import com.ok.common.api.GlobalApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class SplashActivity: BaseActivity() {
    private var dialog: UserAgreementDialog? = null
    var isAgreeMent: Boolean = false
    private  var splashAd: DoubleSplashAd?=null
    private var noNetWorkDialog: NoNetWorkDialog? = null
    private val binding: ActivitySplashBinding by lazy { ActivitySplashBinding.inflate(layoutInflater) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initSpalashAd()
        val splashScreen = installSplashScreen()
        immersionBar {
            transparentStatusBar()
            fitsSystemWindows(false)
            statusBarDarkFont(true)
            transparentNavigationBar()
        }


        setContentView(binding.root)


        isAgreeMent = SpUtils.getInstance().getBoolean(BaseAppConstans.isAgreeMent, false)
        requestStart()
        splashScreen.setOnExitAnimationListener { provider ->
            animLogo(provider)
        }
        binding.tvPrivacyId.text = BaseModuleSpUtils.getInstance().getString(com.hlyj.http.base.tool.lib_hlyj_base.Constants.PRIVACYID)
    }

    override fun onResume() {
        super.onResume()
        if (binding.lottieView != null) {
            binding.lottieView.start()
        }
    }

    private fun requestStart(){
        GlobalApi.getAppRiskConfig(object : ApiCallback<BaseResult<AppRiskConfigBean?>?> {
            override fun onSuccess(model: BaseResult<AppRiskConfigBean?>?) {
                // 请求成功处理
                if (model?.status == 200) {
                    Log.e("qin",model.data.toString())
                    var blackDictValues: List<String> = model.data?.blackList?.map { it.dictValue } ?: emptyList()
                    var whiteDictValues: List<String> = model.data?.whiteList?.map { it.dictValue } ?: emptyList()
                    //Log.e("qin","黑名单列表"+blackDictValues)
                    //Log.e("qin","白名单列表"+whiteDictValues)
                    //获取命中黑名单存进缓存
                    var list_black= DeviceModeUtil.getInstance().getFirstInstalledApp(this@SplashActivity,blackDictValues)
                    BaseModuleSpUtils.getInstance().putStringList(BaseAppConstans.BLACK_LIST,list_black)
                    //获取命中的白名单存进缓存
                    var list_white= DeviceModeUtil.getInstance().checkAppsInstalled(this@SplashActivity,whiteDictValues)
                    BaseModuleSpUtils.getInstance().putStringList(BaseAppConstans.WHITE_LIST,list_white)
                    initSdkAndProgress()
                }
            }

            override fun onFailure(msg: String) {
                initSdkAndProgress()
            }

            override fun onFinish() {

            }
        })
    }
    private fun animLogo(provider: SplashScreenViewProvider) {

        if (provider.iconView.parent == null){
            provider.remove()
            return
        }
        // 获取父容器的高度以确定动画结束的位置
        val parentHeight = (provider.iconView.parent as View).height

        // 获取视图的高度
        val viewHeight: Int = provider.iconView.height
        // 计算视图底部到父容器底部的距离
        val distanceToBottom: Int = parentHeight - provider.iconView.top - viewHeight

        val moveAnim = ObjectAnimator.ofFloat(provider.iconView, View.TRANSLATION_Y, 0f, distanceToBottom.toFloat())
        moveAnim.interpolator = BounceInterpolator()
        moveAnim.duration = 500

        val scaleX = ObjectAnimator.ofFloat(provider.iconView, "scaleX", 1f, 0.35f);
        val scaleY = ObjectAnimator.ofFloat(provider.iconView, "scaleY", 1f, 0.35f);

        AnimatorSet().apply {
            duration = 2000
            play(scaleX).with(scaleY)
            playSequentially(moveAnim)
            doOnEnd {
                provider.remove()
            }
            start()
        }

    }
    //初始化sdk和流程
    private fun initSdkAndProgress() {
        if (Tool.isNetworkAvailable(this@SplashActivity)){
            GlobalApi.getadswitch(object : ApiCallback<BaseResult<GetadswitchResultBean?>?> {
                override fun onSuccess(result: BaseResult<GetadswitchResultBean?>?) {
                    Log.e("qin", "getadswitch")
                    // ... existing code ...
                    if (result != null && result.data != null) {
                        MMKVUtils.saveObject(com.hlyj.http.base.tool.lib_hlyj_base.Constants.initSwitchResultBean, result?.data) //存进mmkv
                        //如果本地广告开关有值 并且值1 不更新
                        val localAdSwitch =
                            BaseModuleSpUtils.getInstance().getString(com.hlyj.http.base.tool.lib_hlyj_base.Constants.NATIVEADSWITCH)
                        if (localAdSwitch.isNullOrEmpty() || localAdSwitch != "1") {
                            // 本地广告开关无值或者值不为 "1" 时执行保存操作
                            BaseModuleSpUtils.getInstance().putString(
                                com.hlyj.http.base.tool.lib_hlyj_base.Constants.NATIVEADSWITCH,
                                result?.data?.adSwitch
                            )
                        }
                        //本地 为 0  不更新
                        var localPrivacySwitch =
                            BaseModuleSpUtils.getInstance().getString(com.hlyj.http.base.tool.lib_hlyj_base.Constants.NATIVEPRIVACYSWITCH)
                        // 当 localPrivacySwitch 不为 "0" 时才执行保存操作
                        if (localAdSwitch.isNullOrEmpty() || localPrivacySwitch != "0") {
                            BaseModuleSpUtils.getInstance().putString(
                                com.hlyj.http.base.tool.lib_hlyj_base.Constants.NATIVEPRIVACYSWITCH,
                                result?.data?.privacySwitch
                            )
                        }
                        when {
                            result.data!!.adSwitch == "0" && result.data!!.privacySwitch == "1" -> {
                                //  ToastUtils.showShort(  this@SplashActivity,"老徐当前执行的是1个流程")
                                // 广告关隐私合规
                                SpUtils.getInstance().putString(BaseAppConstans.APP_PROCESS, "0")
                                if (!SpUtils.getInstance().getBoolean(BaseAppConstans.isAgreeMent)) {
                                    showAgreementtDialog_heimindan()
                                } else {
                                    updateSwitch()
                                    goToMainActivity()
                                }
                            }

                            result.data!!.adSwitch == "1" && result.data!!.privacySwitch == "0" -> {
                                // 广告开，隐私不合规
                                // ToastUtils.showShort(this@SplashActivity,"------老徐当前执行的是2个流程并且隐私不合规")
                                SpUtils.getInstance()
                                    .putString(BaseAppConstans.APP_PROCESS, "1")
                                updateSwitch()

                                ProductEnvConstance.initsdk(this@SplashActivity,object :
                                    BaseApplication.SDKInitCallback {
                                    override fun onInitSuccess() {
                                        runOnUiThread {
                                            loadSplash()
                                        }
                                    }
                                    override fun onInitFailed(errorCode: Int, errorMsg: String) {
                                        goToMainActivity()
                                    }
                                })

                            }

                            result.data!!.adSwitch == "1" && result.data!!.privacySwitch == "1" -> {
                                //ToastUtils.showLongToast("老徐当前执行的是三个流程")
                               // Toast.makeText(this@SplashActivity,"老徐当前执行的是三个流程",Toast.LENGTH_LONG).show()
                                // 广告开，隐私合规
                                SpUtils.getInstance().putString(BaseAppConstans.APP_PROCESS, "2")
                                if (!SpUtils.getInstance().getBoolean(BaseAppConstans.isAgreeMent)) {
                                    showAgreementtDialog()
                                } else {//同意过隐私政策
                                    //   ToastUtils.showLongToast("老徐当前执行的是三个流程并且同意过隐私政策")
                                    updateSwitch()
                                    var resultBean = MMKVUtils.getObject(
                                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.initSwitchResultBean,
                                        GetadswitchResultBean::class.java
                                    )
                                    //应用渠道的非归因是否展示广告
                                    when (resultBean?.natureAdSwitch) {
                                        "0" -> {

                                            // ToastUtils.showShort(this@SplashActivity,"非归因")
                                            SpUtils.getInstance()
                                                .putString(BaseAppConstans.APP_PROCESS, "0")
                                            goToMainActivity()
                                        }
                                        "1" -> {
                                            ProductEnvConstance.initsdk(this@SplashActivity,object :
                                                BaseApplication.SDKInitCallback {
                                                override fun onInitSuccess() {
                                                    runOnUiThread {
                                                        loadSplash()
                                                    }
                                                }
                                                override fun onInitFailed(errorCode: Int, errorMsg: String) {
                                                    goToMainActivity()
                                                }
                                            })
                                        }
                                    }
                                }
                            }
                        }
                    }

                }

                override fun onFailure(errorMessage: String) {
                    Log.e("qin", "onFailure"+errorMessage)
                }

                override fun onFinish() {
                    Log.e("qin", "onFinish")
                }

            })
        }else{
            showNoNetWorkDialog()
        }
    }
    /**
     * 显示隐私协议弹窗
     */
    private fun showAgreementtDialog() {
        dialog = UserAgreementDialog(this)
        dialog!!.show()
        dialog!!.setPrivateId("您好"+"("+BaseModuleSpUtils.getInstance().getString(com.hlyj.http.base.tool.lib_hlyj_base.Constants.PRIVACYID)+")")
        dialog!!.setCancelable(false)
        dialog!!.setOnAgreementListener(object : UserAgreementDialog.AgreementDialogListner {
            override fun onDialogListener(clickType: Boolean) {
                if (clickType) {
                      SpUtils.getInstance().putBoolean(BaseAppConstans.isAgreeMent, true)
                    //应用渠道的非归因是否展示广告
                    updateSwitch()
                    var resultBean = MMKVUtils.getObject(
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.initSwitchResultBean,
                        GetadswitchResultBean::class.java
                    )
                    when (resultBean?.natureAdSwitch) {
                        "0" -> {
                            // ToastUtils.showShort(this@SplashActivity,"非归因")
                            SpUtils.getInstance()
                                .putString(BaseAppConstans.APP_PROCESS, "0")
                            goToMainActivity()
                        }
                        "1" -> {
                            // ToastUtils.showLongToast("非归因用户展示广告—隐私")
                            SpUtils.getInstance()
                                .putString(BaseAppConstans.APP_PROCESS, "2")
                            ProductEnvConstance.initsdk(this@SplashActivity,object :
                                BaseApplication.SDKInitCallback {
                                override fun onInitSuccess() {
                                    runOnUiThread {
                                        loadSplash()
                                    }
                                }
                                override fun onInitFailed(errorCode: Int, errorMsg: String) {
                                    goToMainActivity()
                                }
                            })


                        }
                    }

                } else { //拒绝隐私协议
                    finish()

                }
            }
        })
    }
    /**
     * 显示隐私协议弹窗--黑名单
     */
    private fun showAgreementtDialog_heimindan() {
        dialog = UserAgreementDialog(this)
        dialog!!.show()
        dialog!!.setPrivateId("您好"+"("+BaseModuleSpUtils.getInstance().getString(com.hlyj.http.base.tool.lib_hlyj_base.Constants.PRIVACYID)+")")
        dialog!!.setCancelable(false)
        dialog!!.setOnAgreementListener(object : UserAgreementDialog.AgreementDialogListner {
            override fun onDialogListener(clickType: Boolean) {
                if (clickType) {
                    SpUtils.getInstance().putBoolean(BaseAppConstans.isAgreeMent, true)

                    if (SpUtils.getInstance().getBoolean(BaseAppConstans.isAgreeMent)) {

                        // 使用协程延迟 2 秒
                        lifecycleScope.launch {
                            delay(2000) // 2000ms = 2s这里不设延迟机审过不了
                            updateSwitch()
                            goToMainActivity()
                        }
                    }
                } else { //拒绝隐私协议
                    finish()

                }
            }
        })
    }
    /**
     *进入主页
     */
    private fun goToMainActivity() {
           val intent = Intent(this, MainActivity::class.java)
            startActivity(Intent(intent))
            finish()


    }
    //更新
    private fun updateSwitch() {
        Log.i("qin", "更新用户信息")
        GlobalApi.updateUserInfo(this, object : ApiCallback<BaseResult<GetadswitchResultBean?>?> {
            override fun onSuccess(result: BaseResult<GetadswitchResultBean?>?) {
                Log.i("qin", "更新用户信息成功")
            }

            override fun onFailure(errorMessage: String) {
                Log.i("qin", "更新用户信息onFailure")
            }

            override fun onFinish() {

            }

        })
    }
    private fun loadSplash() {
        Log.d("qin", "loadSplash")
        splashAd?.loadDoubleSplashAd(
            primaryAdUnitId = BaseAdConstants.SPLASH_ID_1,
            secondaryAdUnitId = BaseAdConstants.SPLASH_ID_2,
            container = binding.splashContainer,
            timeout = 15000,
            position = 1,
            isHot = true

        )
    }
    private fun showNoNetWorkDialog() {
        noNetWorkDialog = NoNetWorkDialog(this)
        noNetWorkDialog?.show()
        noNetWorkDialog!!.setCancelable(false)
        noNetWorkDialog!!!!.setOnDissmissListener(object : NoNetWorkDialog.noNetworkDialogListner {
            override fun NoNet() {
                finish()
            }

        })

    }

    private fun initSpalashAd(){
        splashAd = DoubleSplashAd(this, object : IAdviewNotLoadSplashListener {
            override fun onTrigger(adUnitId: String) {
                val logContent = listOf(
                    mapOf(
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TYPE to com.hlyj.http.base.tool.lib_hlyj_base.Constants.TRIGGER,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ to BaseModuleSpUtils.getInstance().getInt(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ,1),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO to BaseModuleSpUtils.getInstance().getString(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADFORMAT to com.hlyj.http.base.tool.lib_hlyj_base.Constants.SPLASH,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.PLACEMENTID to adUnitId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TIME to System.currentTimeMillis().toString()
                    )

                )
                //  Log.e("ProductEnvConstance", "onTrigger${logContent}")
                GlobalApi.sendLog(logContent)
            }

            override fun onAdShow(ad: CSJSplashAd, adUnitId: String, position:Int) {
                Log.e("splash", "onAdShow${position}")
                val logContent = listOf(
                    mapOf(
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TYPE to com.hlyj.http.base.tool.lib_hlyj_base.Constants.SHOW,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ to BaseModuleSpUtils.getInstance().getInt(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ,1),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO to BaseModuleSpUtils.getInstance().getString(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADFORMAT to com.hlyj.http.base.tool.lib_hlyj_base.Constants.SPLASH,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.PLACEMENTID to adUnitId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADSOURCEID to ad.mediationManager.showEcpm.slotId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE to position,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SHOWID to ad.mediationManager.showEcpm.requestId,
                        // Constants.ECPM to BigDecimal(adView.getEcpm()).toPlainString()
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ECPM to ad.mediationManager.showEcpm.ecpm,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TIME to System.currentTimeMillis().toString(),
                        //   Constants.DATA to JsonUtil.parseStringToJsonWithMsg("这是自定义"),//这里
                    )

                )
                // Log.e("ProductEnvConstance", "onAdShow${logContent}")
                GlobalApi.sendLog(logContent)
            }

            override fun onAdClick(ad: CSJSplashAd, adUnitId: String) {
                var ocCodee = BaseModuleSpUtils.getInstance().getInt(com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE, 0)
                val logContent = listOf(
                    mapOf(
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TYPE to com.hlyj.http.base.tool.lib_hlyj_base.Constants.CLICK,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ to BaseModuleSpUtils.getInstance().getInt(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ,1),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO to BaseModuleSpUtils.getInstance().getString(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADFORMAT to com.hlyj.http.base.tool.lib_hlyj_base.Constants.SPLASH,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.PLACEMENTID to adUnitId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADSOURCEID to ad.mediationManager.showEcpm.slotId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE to ocCodee,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SHOWID to ad.mediationManager.showEcpm.requestId,
                        // Constants.ECPM to BigDecimal(adView.getEcpm()).toPlainString()
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ECPM to ad.mediationManager.showEcpm.ecpm,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TIME to System.currentTimeMillis().toString(),
                        //   Constants.DATA to JsonUtil.parseStringToJsonWithMsg("这是自定义"),//这里
                    )

                )
                // Log.e("ProductEnvConstance", "onAdShow${logContent}")
                GlobalApi.sendLog(logContent)
            }

            override fun onAdClose(ad: CSJSplashAd, adUnitId: String) {
                var ocCodee = BaseModuleSpUtils.getInstance().getInt(com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE, 0)
                val logContent = listOf(
                    mapOf(
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TYPE to com.hlyj.http.base.tool.lib_hlyj_base.Constants.CLOSE,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ to BaseModuleSpUtils.getInstance().getInt(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ,1),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO to BaseModuleSpUtils.getInstance().getString(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADFORMAT to com.hlyj.http.base.tool.lib_hlyj_base.Constants.SPLASH,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.PLACEMENTID to adUnitId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADSOURCEID to ad.mediationManager.showEcpm.slotId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE to ocCodee,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SHOWID to ad.mediationManager.showEcpm.requestId,
                        // Constants.ECPM to BigDecimal(adView.getEcpm()).toPlainString()
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ECPM to ad.mediationManager.showEcpm.ecpm,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TIME to System.currentTimeMillis().toString(),
                        //   Constants.DATA to JsonUtil.parseStringToJsonWithMsg("这是自定义"),//这里
                    )

                )
                // Log.e("ProductEnvConstance", "onAdShow${logContent}")
                GlobalApi.sendLog(logContent)

            }

            override fun onError(msg: String) {
                var ocCodee = BaseModuleSpUtils.getInstance().getInt(com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE, 0)
                val logContent = listOf(
                    mapOf(
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TYPE to com.hlyj.http.base.tool.lib_hlyj_base.Constants.FAIL,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ to BaseModuleSpUtils.getInstance().getInt(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ,1),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO to BaseModuleSpUtils.getInstance().getString(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADFORMAT to com.hlyj.http.base.tool.lib_hlyj_base.Constants.SPLASH,
                        // Constants.PLACEMENTID to splash,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE to ocCodee,
                        // Constants.ECPM to BigDecimal(adView.getEcpm()).toPlainString()
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.DATA to JsonUtil.parseStringToJsonWithMsg(msg),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TIME to System.currentTimeMillis().toString()
                    )

                )
                GlobalApi.sendLog(logContent)

            }

            override fun onSuccess(ad: CSJSplashAd, adUnitId: String) {
                var ocCodee = BaseModuleSpUtils.getInstance().getInt(com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE, 0)
                val logContent = listOf(
                    mapOf(
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TYPE to com.hlyj.http.base.tool.lib_hlyj_base.Constants.LOAD,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ to BaseModuleSpUtils.getInstance().getInt(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.SEQ,1),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO to BaseModuleSpUtils.getInstance().getString(
                            com.hlyj.http.base.tool.lib_hlyj_base.Constants.HARDWAREINFO),
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADFORMAT to com.hlyj.http.base.tool.lib_hlyj_base.Constants.SPLASH,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.PLACEMENTID to adUnitId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ADSOURCEID to ad.mediationManager.showEcpm.slotId,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.OCCODE to ocCodee,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.SHOWID to ad.mediationManager.showEcpm.requestId,
                        // Constants.ECPM to BigDecimal(adView.getEcpm()).toPlainString()
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.ECPM to ad.mediationManager.showEcpm.ecpm,
                        com.hlyj.http.base.tool.lib_hlyj_base.Constants.TIME to System.currentTimeMillis().toString(),
                        //   Constants.DATA to JsonUtil.parseStringToJsonWithMsg("这是自定义"),//这里
                    )

                )
                // Log.e("ProductEnvConstance", "onAdShow${logContent}")
                GlobalApi.sendLog(logContent)
            }



            override fun onSkipped() {

            }

            override fun goMain() {
                goToMainActivity()

            }
        })
    }

    override fun onDestroy() {
        super.onDestroy()
        binding.lottieView.stop()
    }
}